package com.spr.enums;


import java.util.Objects;

/**
 * 操作日志枚举
 */
public enum OperaStatus {

    SUCCESS(0,"SUCCESS"),
    FAIL(1,"FAIL"),

    ;

    private final Integer type;
    private final String statusString;

    OperaStatus(Integer type, String businessTypeString) {
        this.type = type;
        this.statusString = businessTypeString;

    };

    public Integer getType() {
        return type;
    }

    public String getOperaStatusString() {
        return statusString;
    }
    public static String getBusinessTypeStringByBusinessType(OperaStatus operaStatus){
        if (Objects.isNull(operaStatus)){
            return null;
        }
        return operaStatus.getOperaStatusString();
    }
    public static Integer getTypeByStatusString(OperaStatus operaStatus){
        if (Objects.isNull(operaStatus)){
            return null;
        }
        return operaStatus.getType();
    }


    public static Integer getTypeByBusinessTypeString(String businessTypeString){
        if (Objects.isNull(businessTypeString)){
            return null;
        }
        for (OperaStatus value : OperaStatus.values()) {
            if (value.getOperaStatusString().equals(businessTypeString)){
                return value.getType();
            }
        }
        return null;
    }



}
